def solution():
n = int(input())
c = list(map(int, input().split()))
cnt = 0
mini = []
c.sort()
for i in range(n-1):
mini.append(abs((c[i])-(c[i+1])))
mini_v = min(mini)
for val in mini:
if val == mini_v:
cnt += 1
print("{} {}".format(mini_v, cnt))
t = 1
while t:
t -= 1
solution()
/*************************************************************************
> File Name: a.cpp
> Author:123emm
> Mail: [email protected]
> Created Time: 2023年03月10日 星期五 15时23分19秒
************************************************************************/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
int n; cin >> n;
vector <int> A(n);
for (auto &a : A) cin >> a;
sort(A.begin(), A.end());
int mi = 2e9 + 10;
for (int i = 1; i < n; i++) {
mi = min(mi, A[i] - A[i - 1]);
}
int ans = 0;
for (int i = 1; i < n; i++) {
if (A[i] - A[i - 1] == mi) ans++;
}
cout << mi << " " << ans;
return 0;
}
1607A - Linear Keyboard | EQUALCOIN Equal Coins |
XOREQN Xor Equation | MAKEPAL Weird Palindrome Making |
HILLSEQ Hill Sequence | MAXBRIDGE Maximise the bridges |
WLDRPL Wildcard Replacement | 1221. Split a String in Balanced Strings |
1002. Find Common Characters | 1602A - Two Subsequences |
1555A - PizzaForces | 1607B - Odd Grasshopper |
1084A - The Fair Nut and Elevator | 1440B - Sum of Medians |
1032A - Kitchen Utensils | 1501B - Napoleon Cake |
1584B - Coloring Rectangles | 1562B - Scenes From a Memory |
1521A - Nastia and Nearly Good Numbers | 208. Implement Trie |
1605B - Reverse Sort | 1607C - Minimum Extraction |
1604B - XOR Specia-LIS-t | 1606B - Update Files |
1598B - Groups | 1602B - Divine Array |
1594B - Special Numbers | 1614A - Divan and a Store |
2085. Count Common Words With One Occurrence | 2089. Find Target Indices After Sorting Array |